using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.Storage;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace MicroMsg.UI.Page
{
	public class ShowQRCodeListPage : BasePage
	{
		private const string TAG = "ShowQRCodeListPage";
		private ShowQRCodeListFromType mFromType;
		private EventWatcher mWatchContactListChange;
		private bool mBIsForeigner;
		internal Grid LayoutRoot;
		internal TextBlock txtTitle;
		internal Button btnToQWeibo;
		internal TextBlock txtAdd;
		internal Button btnToQZone;
		internal Button btnToSina;
		internal Button btnToFacebook;
		private bool _contentLoaded;
		public ShowQRCodeListPage()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.Page_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.Page_Unloaded));
		}
		private void Page_Loaded(object sender, RoutedEventArgs e)
		{
			Log.smethod_5("ShowQRCodeListPage", "Page_Loaded");
		}
		private void Page_Unloaded(object sender, RoutedEventArgs e)
		{
			Log.smethod_5("ShowQRCodeListPage", "Page_Unloaded");
		}
		protected override void OnPageIn(object[] object_0)
		{
			Log.smethod_5("ShowQRCodeListPage", "OnPageIn");
			int pageCount = PageManager.getInstance().GetPageCount();
			if (1 == pageCount)
			{
				this.mFromType = ShowQRCodeListFromType.FromType_ShowQRCode;
			}
			else
			{
				this.mFromType = ShowQRCodeListFromType.FromType_UserQRCode;
			}
			this.initUI();
		}
		protected override void OnPageOut()
		{
			Log.smethod_5("ShowQRCodeListPage", "OnPageOut");
		}
		protected override void OnPageBack()
		{
			Log.smethod_5("ShowQRCodeListPage", "OnPageBack");
		}
		private void registerEvent()
		{
			if (this.mWatchContactListChange == null)
			{
				this.mWatchContactListChange = new EventWatcher(this, this, new EventHandlerDelegate(this.OnContactChange));
				EventCenter.registerEventWatcher(EventConst.ON_STORAGE_CONTACT_ADD, this.mWatchContactListChange);
			}
		}
		private void unRegisterEvent()
		{
			if (this.mWatchContactListChange != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_STORAGE_CONTACT_ADD, this.mWatchContactListChange);
				this.mWatchContactListChange = null;
			}
		}
		private void OnContactChange(EventWatcher watcher, BaseEventArgs evtArgs)
		{
		}
		private void btnToQWeibo_Click(object sender, RoutedEventArgs e)
		{
			if (AccountMgr.nBindQQ < 50u)
			{
				MMMessageBox mMMessageBox = MMMessageBox.Show("", strings.Common_NeedBindQQ, true, strings.COM_Yes, strings.COM_No);
				mMMessageBox.ReturnEvent = new DlgReturnEvent(this.askBindingQQDlgReturn);
				return;
			}
			if (!AccountMgr.HasTWeibo())
			{
				MessageBoxManager.ShowToast(strings.Setting_NoTentcentWeibo, 2500, null, false);
				return;
			}
			this.showQrCodeTo(SendCardType.MM_SENDCARD_QQBLOG);
		}
		private void btnToQZone_Click(object sender, RoutedEventArgs e)
		{
			if (AccountMgr.nBindQQ < 50u)
			{
				MMMessageBox mMMessageBox = MMMessageBox.Show("", strings.Common_NeedBindQQ, true, strings.COM_Yes, strings.COM_No);
				mMMessageBox.ReturnEvent = new DlgReturnEvent(this.askBindingQQDlgReturn);
				return;
			}
			this.showQrCodeTo(SendCardType.MM_SENDCARD_QZONE);
		}
		public void askBindingQQDlgReturn(DlgReturnEventArg dlgReturnEventArg_0)
		{
			if (MMMessageBox.GetUserClickResult(dlgReturnEventArg_0) == 0)
			{
				string text = "findFriend";
				base.GoToPage("/Source/UI/QQFriends/GoBindQQ.xaml", new object[]
				{
					text
				}, false);
			}
		}
		private void btnToSina_Click(object sender, RoutedEventArgs e)
		{
			this.showQrCodeTo(SendCardType.MM_SENDCARD_SINABLOG);
		}
		private void btnToFacebook_Click(object sender, RoutedEventArgs e)
		{
			Account curAccount = AccountMgr.getCurAccount();
			if (curAccount == null)
			{
				return;
			}
			if (curAccount.FaceBookFlag <= 0u)
			{
				FaceBookBind.ShowBindPage(this, false);
				return;
			}
			this.showQrCodeTo(SendCardType.MM_SENDCARD_FACEBOOK);
		}
		private void btn_KeyDown(object sender, MouseButtonEventArgs e)
		{
		}
		private void btn_KeyUp(object sender, MouseButtonEventArgs e)
		{
		}
		private void btnSearchFriend_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
		{
		}
		private void btnSearchFriend_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
		{
		}
		private void btnSearchFriend_MouseLeave(object sender, MouseEventArgs e)
		{
		}
		private void btnSearchFriend_MouseEnter(object sender, MouseEventArgs e)
		{
		}
		private void initUI()
		{
			this.mBIsForeigner = this.bIsForeigner();
			if (this.mBIsForeigner)
			{
				if (AccountMgr.nBindQQ < 50u)
				{
					this.btnToQWeibo.set_Visibility(1);
					this.btnToQZone.set_Visibility(1);
					this.btnToSina.set_Visibility(1);
					return;
				}
			}
			else
			{
				Account curAccount = AccountMgr.getCurAccount();
				if (curAccount == null)
				{
					return;
				}
				if (curAccount.FaceBookFlag <= 0u)
				{
					this.btnToFacebook.set_Visibility(1);
				}
			}
		}
		private bool bIsForeigner()
		{
			RegionInfo currentRegion = RegionInfo.get_CurrentRegion();
			return currentRegion != null && currentRegion.get_TwoLetterISORegionName() != "CN";
		}
		private void showQrCodeTo(SendCardType sendCardType)
		{
			if (this.mFromType == ShowQRCodeListFromType.FromType_ShowQRCode)
			{
				base.GoToPage("/Source/Plugin/QRCode/UI/ShareQRCodePreViewPage.xaml", new object[]
				{
					sendCardType
				}, false);
				return;
			}
			if (this.mFromType == ShowQRCodeListFromType.FromType_UserQRCode)
			{
				base.GoToPage("/Source/Plugin/QRCode/UI/EditQRCodeContentPage.xaml", new object[]
				{
					sendCardType
				}, false);
			}
		}
		protected override void OnBackKeyPress(CancelEventArgs cancelEventArgs_0)
		{
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/QRCode/UI/ShowQRCodeListPage.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.txtTitle = (TextBlock)base.FindName("txtTitle");
			this.btnToQWeibo = (Button)base.FindName("btnToQWeibo");
			this.txtAdd = (TextBlock)base.FindName("txtAdd");
			this.btnToQZone = (Button)base.FindName("btnToQZone");
			this.btnToSina = (Button)base.FindName("btnToSina");
			this.btnToFacebook = (Button)base.FindName("btnToFacebook");
		}
	}
}
